home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / boost4.zip / MBLOCK.PAS < prev    next >
Pascal/Delphi Source File  |  1988-10-23  |  1KB  |  61 lines

  1. Program Mblock;
  2.  
  3.  { Demonstrates moving a box around on the screen
  4.    using the arrow keys }
  5.  
  6. uses crt,BOSHARE;
  7.  
  8. var
  9.    x1,x2,x3,
  10.    y1,y2,y3  : integer;
  11.    c : char;
  12.    hit : boolean;
  13.  
  14. Const
  15.    UpAr = #72;
  16.    DnAr = #80;
  17.    RtAr = #77;
  18.    LfAr = #75;
  19.  
  20. BEGIN
  21.  
  22.    {--- Clear the screen, define & draw the box }
  23.    ClrScr;
  24.    putstr(h,Center('Use arrow keys to move box - Esc quits',80,' '),1,1,14);
  25.    x1 := 1;
  26.    y1 := 1;
  27.    x2 := 4;
  28.    y2 := 4;
  29.    x3 := x1;
  30.    y3 := y1;
  31.    box ( x1,y1,x2,y2,1,14 );
  32.  
  33.    {--- Move box according to arrow keys; quit if Escape }
  34.    repeat
  35.       hit := true;
  36.       c := readkey;
  37.       if c = #0 then begin
  38.          c := readkey;
  39.          case c of
  40.             UpAr : if y1 > 1 then
  41.                       y3 := y3 -1;
  42.             DnAr : if y2 < 25 then
  43.                       y3 := y3 +1;
  44.             RtAr : if x2 < 80 then
  45.                       x3 := x3 +1;
  46.             LfAr : if x1 > 1 then
  47.                       x3 := x3 -1;
  48.          else
  49.             hit := false;
  50.          end;
  51.          if hit then begin
  52.             MoveBlkr ( x1,y1,x2,y2,x3,y3,14);
  53.             x1 := x3;
  54.             x2 := x1 + 3;
  55.             y1 := y3;
  56.             y2 := y1 + 3;
  57.          end;
  58.       end;
  59.    until c  =  #27;
  60.  
  61. END.